package com.doudoukeji.service.Activity.my.edituser;

import android.content.Context;
import android.util.Log;

import com.doudoukeji.service.Activity.ConstantValue;
import com.doudoukeji.service.Bean.Token;
import com.doudoukeji.service.Http.MyHttpResponseHandler;
import com.loopj.android.http.RequestParams;
import com.sanhai.android.mvp.BasePresenter;
import com.sanhai.android.service.http.BusinessClient;
import com.sanhai.android.service.http.Response;

import org.apache.http.Header;

/**
 * @version 2.0
 * @类描述：
 * @项目名称：ddgh
 * @类名称： HostpitalListPresenter
 * @包名称： com.doudoukeji.service.Activity.my.edituser
 * @创建人： zhanjunjie
 * @创建时间：2016/3/16 15:13
 * @修改人：
 * @修改时间：2016/3/16 15:13
 * @修改备注： new parent class(用一句话描述修改了什么)
 */
public class EditUserInfoPresenter extends BasePresenter {

    private EditUserInfoView view;

    public EditUserInfoPresenter(Context context, EditUserInfoView view) {
        super(context, view);
        this.view = view;
    }

    public void updateUserInfo(String phone, String checkCode, String name, String hospitals, String services) {
        RequestParams params = new RequestParams();
        params.put("userId", Token.getId());
        params.put("phone", phone);
        params.put("checkCode", checkCode);
        params.put("name", name);
        params.put("hospitals", hospitals);
        params.put("services", services);
        params.put("token", Token.getToken());
        Log.d("aaaa", ConstantValue.editorInfo + "?userId=" + Token.getId() + "&phone=" + phone + "&checkCode=" + checkCode + "&name=" + name + "&hospitals=" + hospitals + "&services=" + services + "&token=" + Token.getToken());
        BusinessClient.post(ConstantValue.editorInfo, params, new MyHttpResponseHandler(view) {
            @Override
            public void onMyResponse(Response response) {
                if (response.isSucceed()) {
                    view.updateSucced();
                } else {
                    view.showToastMessage(response.getMsg());
                }
            }

            @Override
            public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) {
                super.onFailure(i, headers, bytes, throwable);
                view.updateFail();
            }
        });
    }


}
